<template>
    <view>
        <u-sticky>
            <view class="search">
                <u-search placeholder="请输入标题关键字" v-model="keyword" @search="search" @custom='search'></u-search>
            </view>
        </u-sticky>
        <view class="list">
            <view class="list-item" v-for="(item,index) in gongaoList" :key="index" @click="toxiangqing(item)">
                <view class="list-img">
                    <image class="w100h100" :src="item.infoImage" mode=""></image>
                </view>
                <view class="list-info">
                    <view class="info-title">
                        {{item.name}}
                    </view>
                    <!--  <view class="info-content" v-html="item.content">

                    </view> -->
                    <view class="info-type">
                        <view class="" style="margin-right: 20rpx;">
                            {{item.updateTime}}
                        </view>
                    </view>
                </view>
            </view>
        </view>

    </view>
</template>

<script>
    import {
        carouselChartlist,
        realtimeInfopage
    } from '@/api/home/index.js'
    export default {
        data() {
            return {
                keyword: '',
                gongaoList: [],
            }
        },
        async onLoad() {

            let res1 = await realtimeInfopage({
                size: '10',
                page: '1',
                showFlag: 'Y',
                timeType: 'new_time',
                name: this.keyword
            })
            console.log(res1, 333333333);
            res1.data.forEach(el => {
                el.updateTime = el.updateTime.slice(0, 16)
            })
            this.gongaoList = res1.data
        },
        methods: {
            async search() {
                let res1 = await realtimeInfopage({
                    size: '100',
                    page: '1',
                    showFlag: 'Y',
                    timeType: 'new_time',
                    name: this.keyword
                })
                res1.data.forEach(el => {
                    el.updateTime = el.updateTime.slice(0, 16)
                })
                this.gongaoList = res1.data
            },
            toxiangqing(val) {
                uni.navigateTo({
                    url: `/packageA/pages/gonggaoDetails/gonggaoDetails?id=${val.id}`
                })
            }

        }
    }
</script>

<style lang="scss" scoped>
    .search {

        top: 80rpx;
        z-index: 999;
        padding: 20rpx;
        background-color: #fff;
        box-shadow: -2px 12px 5px #e3e3e3;
        -moz-box-shadow: -2px 12px 5px #e3e3e3;
        -webkit-box-shadow: -2px 12px 5px #e3e3e3;
    }

    .list {
        box-sizing: border-box;
        width: 740rpx;
        padding: 20rpx;
        margin: 0 auto;


        .list-item {

            margin: 20rpx 0;
            background-color: #ffffff;
            display: flex;
            flex-shrink: 0;
            padding: 20rpx;
            border-radius: 40rpx;

            .list-img {
                flex-shrink: 0;
                width: 250rpx;
                height: 150rpx;
                margin-right: 30rpx;
                border-radius: 10rpx;
                overflow: hidden;
            }

            .list-info {
                flex-shrink: 0;
                width: 360rpx;

                .info-title {
                    box-sizing: border-box;
                    margin: 5rpx;
                    width: 100%;
                    font-size: 32rpx;
                    color: $u-main-color;
                    // font-weight: 700;
                    display: -webkit-box;
                    -webkit-box-orient: vertical;
                    -webkit-line-clamp: 2;

                    overflow: hidden;
                    text-overflow: ellipsis;

                }

                .info-content {
                    box-sizing: border-box;
                    margin: 5rpx;
                    width: 100%;
                    font-size: 28rpx;
                    color: #666666;
                    display: -webkit-box;
                    -webkit-box-orient: vertical;
                    -webkit-line-clamp: 2;

                    overflow: hidden;
                    text-overflow: ellipsis;
                }

                .info-type {
                    box-sizing: border-box;
                    // padding: 5rpx;
                    display: flex;
                    justify-content: flex-end;
                    color: $u-main-color;
                    font-size: 26rpx;
                    color: #666666;
                    padding: 20rpx 0;
                }
            }
        }
    }
</style>